<?php
class entityrepo
{
    private static $data = array();    
    private static $insertlist  = array();
    private static $updatelist  = array();
    private static $deletelist  = array();
    public static function put($entity)
    {
        self::$data[$entity->id] = &$entity;
    }

    public static function search($entity)
    {
        return self::$data[$entity->id];
    }

    public static function update($entity)
    {
        self::$data[$entity->id] = $entity;
    }

    public static function delete($entity)
    {
        unset(self::$data[$entity->id]);
    }

    public static function getall()
    {
        return self::$data;
    }

    public static function getinsertlist()
    {
        foreach(self::$data as $id => $entity)
        {
            if($entity->isinsert)
            {
                self::$insertlist[$entity->id] = $entity;
            }
        } 
        return self::$insertlist;
    }

    public static function getupdatelist()
    {
        foreach(self::$data as $id => $entity)
        {
            if($entity->isupdate  && ($entity->isdelete != true || $entity->isinsert != true))
            {
                self::$updatelist[$entity->id] = $entity;
            }
        } 
        return self::$updatelist;
    }

    public static function getdeletelist()
    {
        foreach(self::$data as $id => $entity)
        {
            if($entity->isdelete)
            {
                self::$deletelist[$entity->id] = $entity;
            }
        } 
        return self::$deletelist;
    }
}
